<template>
    <div class="show" v-show="DPisopen, props.isopen">
        <main>
            <div class="closeShow a" @click="closeShow()">关闭</div>
            <div class="sh_title">{{ props.name }}</div>
            <div class="sh_body">
                <div class="sh_author">
                    <span>作者:</span>
                    <span>{{ info[0] }}</span>
                </div>
                <div class="sh_time">
                    <span>发布时间:</span>
                    <span>{{ info[1] }}</span>
                </div>
                <div class="sh_desc">
                    <span>说明:</span>
                    <span>{{ info[2] }}</span>
                </div>
                <div class="sh_download">
                    <span>下载:</span>
                    <span>主页 加微信</span>
                </div>
                <div class="sh_img">
                    <div class="sh_img_title">图片预览:</div>
                    <div class="sh_imgMain">
                        <div class="sh_imgBody">
                            <div class="demo-image__preview" v-for="(item2, index) in imgData[DPname]" :key="item2">
                                <el-image style="width: 300px" :src="item2" :zoom-rate="1.2" :max-scale="5"
                                    :min-scale="0.2" :preview-src-list="srcList" :initial-index="index" fit="cover" />
                            </div>
                        </div>
                    </div>
                </div>
            </div>

        </main>
    </div>
</template>
<script setup>
import { useStore } from 'vuex'
const store = useStore()
import { ref, defineProps, watchEffect } from 'vue';

// import { imgData } from '/public/js/text.js';
// import { infoData } from '/public/js/text.js';


const DPname = ref("html作业_小说")
const DPisopen = ref(false)

const props = defineProps({
    time: Number,
    name: String,
    isopen: Boolean,
});

const url = ref("")
const srcList = ref([])
const info = ref([])

var imgName
var imgUrlLen

watchEffect(() => {
    props.time
    if (props.isopen == true) {
        DPname.value = props.name
        DPisopen.value = props.isopen
    }

})
function load_textjs() {
    return import('/public/js/text.js')
}
const imgData = ref({})
const infoData = ref({})
load_textjs().then((module) => {
    imgData.value = module.imgData
    infoData.value = module.infoData

    info.value = infoData.value[DPname.value]
    imgName = imgData.value[DPname.value]
    imgUrlLen = imgData.value["html作业_小说"].length
    url.value = imgName
    srcList.value = imgData.value[DPname.value]

}).catch((error) => {
    console.error('模块加载失败:', error);
});

function closeShow() {
    DPisopen.value = false;
    store.state.publish_lock = false
}
</script>
<style scoped>
.show {
    position: fixed;
    top: 0;
    left: 0;
    /* height: calc(100vh - var(--headerHeight)); */
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    background-color: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    flex-direction: column;
    align-items: center;
}

main {
    margin-top: 3em;
    width: 100%;
    max-width: 1100px;
    padding-left: 10px;
    padding-right: 10px;
    text-align: center;
    position: relative;
    overflow: auto;
}

.closeShow {
    position: fixed;
    top: 20px;
    left: 10px;
    border: 2px solid;
    border-radius: 6px;
    font-size: 18px;
    font-weight: bold;
    padding: 2px 6px;
    transition: 0.3s;
}

.closeShow:hover {
    color: rgb(255, 56, 56);
}

.sh_title {
    font-size: 30px;
    color: rgb(0, 165, 110);
    padding-block: 10px;
}

.sh_body {
    max-width: 1000px;
    padding-top: 20px;
    margin: auto;
    text-align: left;
    font-size: 18px;
}

.sh_time,
.sh_author,
.sh_desc,
.sh_download {
    padding-block: 10px;
}

.sh_body span:nth-child(1) {
    padding-left: 10px;
    padding-right: 10px;
    color: rgb(202, 98, 0);
}

.sh_img {
    margin-bottom: 20px;
}

.sh_img_title {
    font-size: x-large;
    padding-left: 10px;
    padding-right: 10px;
    padding-block: 10px;
}

.sh_imgMain {
    background-color: rgba(185, 185, 185, 0.3);
    padding: 10px 5px;
    width: 100%;
    display: flex;
    align-items: center;
}

.sh_imgBody {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
}

.demo-image__preview {
    width: fit-content;
    padding-left: 10px;
    padding-right: 10px;
    margin-top: 20px;
}
</style>